package com.bw.controller;

import com.bw.doman.sugarDTO;
import com.bw.service.sugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class sugarController {

    @Autowired
    sugarService sugarService;

    //按照第二大类交易额排名
    @RequestMapping("list")
    public Map list(){
        List<sugarDTO> list = sugarService.getList();
        return SugarUtil.getPieData(list);
    }

    //按品牌交易额排名
    @RequestMapping("list2")
    public Map list2(){
        List<sugarDTO> list = sugarService.getList2();
        return SugarUtil.getBarData(list);
    }

    //按省份交易额排名
    @RequestMapping("list3")
    public Map list3(){
        List<sugarDTO> list = sugarService.getList3();
        return SugarUtil.getMapData(list);
    }

    //（11）订单总成交金额的存储过程
    @RequestMapping("list4")
    public Map list4(){
       Double total= sugarService.getList4();
        Map map = new HashMap();
        map.put("status",0);
        map.put("data",total);
        return map;
    }


    //（12）按SPU 分组订单金额
    @RequestMapping("list5")
    public String list5(){
        List<sugarDTO> list= sugarService.getList5();
        List list1 = new ArrayList();
        list1.add("名称");
        list1.add("金额");
        return SugarUtil.getTablePlayData(list1,list);
    }
}
